<?php

/**
 * Created by PhpStorm.
 * User: wangan
 * Date: 2018/8/1
 * Time: 14:14
 * 监控服务
 */
class monitor
{
    const PORT = 8814;

    //监控端口
    public function port(){
        $shell = 'netstat -anp |grep '.self::PORT.' |grep LISTEN |wc -l';
        $result = shell_exec($shell);
        if($result < 1){ //进程出错
            //todo
        }
        echo $result;
    }

}

swoole_timer_tick(2000, function () {
    (new monitor())->port();
});

